<?php

namespace app\apiadmin\controller\live;

use app\apiadmin\controller\liveManager\LiveStatus;
use app\apiadmin\controller\live\MyOrder;
use app\apiadmin\service\liveManager\LiveManagerService;
use app\apiadmin\service\statics\LiveUserGetDataService;
use app\apiadmin\service\unionapp\UnionAppService;
use app\common\alipay\aop\AopClient;
use app\common\alipay\aop\request\AlipayTradeWapPayRequest;
use app\common\controller\BaseController;
use app\common\utils\Res;
use DateTime;
use DateTimeZone;
use think\facade\Db;
use WeChatPay\Builder;
use WeChatPay\Crypto\AesGcm;
use WeChatPay\Crypto\Rsa;
use WeChatPay\Formatter;
use WeChatPay\Util\PemUtil;

class UnionApp extends BaseController
{

    /**
     * @author: zwx
     * @Description: 获取购物车数据
     * @Date: 2024-05-15 14:36:42
     */
    public function gouwuche()
    {

        // $goodslist = [[
        //     "id"=>1,
        //     "courseid"=>1,
        //     "img"=>'http://1251993779.vod2.myqcloud.com/0f0890f7vodcq1251993779/d3d5661d1397757886696328054/AJj1VHanehEA.jpg',
        //     "title"=>'英语二合一(歌谣课+英文绘本故事)',
        //     "detail"=>'限时免费',
        //     "biaoqian"=>[[
        //         "name"=>'热销1000件',
        //         "style"=>'color:red;border-color:red;'
        // ], [
        //         "name"=>'永久有效',
        //         "style"=>'color:red;border-color:red;'
        //     ]]
        // ], [
        //     "id"=>2,
        //     "courseid"=>2,
        //     "img"=>'http://1251993779.vod2.myqcloud.com/0f0890f7vodcq1251993779/a79ddf98388912588335109136/pW2wE8oePe8A.jpg',
        //     "title"=>'外教情景课',
        //     "detail"=>'限时免费',
        //     "biaoqian"=>[[
        //         "name"=>'热销800件',
        //         "style"=>'color:red;border-color:red;'
        //     ], [
        //         "name"=>'永久有效',
        //         "style"=>'color:red;border-color:red;'
        //     ]]
        // ]];

        $goodslist = DB::table('xh_siyu_course')->where(array('del' => 0, 'state' => 1))->order('sort')->select();

        $biaoqian = [
            [
                "name" => '热销5万+',
                "style" => 'color:red;border-color:red;',
            ],
            [
                "name" => '永久有效',
                "style" => 'color:red;border-color:red;',
            ],
        ];

        foreach ($goodslist as $k => $v) {
            $goodslist[$k]['title'] = $v['name'];
            $goodslist[$k]['detail'] = '限时免费';
            $goodslist[$k]['biaoqian'] = $biaoqian;
        }

        return Res::ok($goodslist);
    }

    /**
     * @author: zwx
     * @Description: 创建订单  废弃
     * @Date: 2024-05-15 14:36:42
     */
    public function createOrder()
    {
        $param = $this->request->post();
        $result = UnionAppService::createOrder($param);
        return Res::ok($result);

    }

    /**
     * @author: zwx
     * @Description: 生成微信支付订单预下单ID
     * @param {*} $openid   用户openid
     * @param {*} $total   金额  单位：分
     * @param {*} $coursename  课程名称
     * @param {*} $courseid  课程ID
     * @param {*} $out_trade_no  订单号
     * @param {*} $time   下单时间  时间戳
     * @param {*} $liveId 直播ID
     * @Date: 2024-05-22 18:34:38
     */

    public static function createPrepayId($openid, $total, $coursename, $courseid, $out_trade_no, $time, $liveId, $user_id, $event_id = '')
    {
        // 创建DateTime对象
        $dateTime = new DateTime(date('Y-m-d H:i:s', $time));

        // 设置时区，如果需要的话
        $dateTime->setTimezone(new DateTimeZone('Asia/Shanghai'));

        // 生成RFC3339格式的时间字符串
        $time_expire = $dateTime->format(DateTime::RFC3339);

        $url = 'https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi';

        $amount = array();
        $amount['total'] = intval($total);
        $amount['currency'] = 'CNY';

        $payer = array();
        $payer['openid'] = $openid;

        $json = array();
        $json['appid'] = 'wx6d35f289e388fcdc';
        $json['mchid'] = '1674971019';
        $json['notify_url'] = 'https://liveapi.banxued.com/apiadmin/unionapp/notify';

        $json['description'] = $coursename;
        $json['out_trade_no'] = $out_trade_no;
        $json['time_expire'] = $time_expire;
        $attach = [
            $liveId, //直播id
            $user_id, //用户id
            $event_id, //事件id
            $courseid, //课程id
        ];
        $json['attach'] = implode('_', $attach);
        // $json['attach'] = $liveId . '_' . $user_id . '_' . $event_id . '_' . $courseid;

        $json['amount'] = $amount;
        $json['payer'] = $payer;

        //获取prepay_id
        $result = self::client_post($url, $json);

        if ($result['code'] != 200) {
            return Res::error($result);
            die;
        }

        //组合数据
        $data = array();
        $data['appId'] = $json['appid'];
        $data['timeStamp'] = $time;
        $data['nonceStr'] = Formatter::nonce();
        $data['package'] = 'prepay_id=' . json_decode($result['body'], true)['prepay_id'];
        $data['signType'] = 'RSA';
        $data['paySign'] = self::makeSign($data['appId'], $data['timeStamp'], $data['nonceStr'], $data['package']); //签名，使用字段AppID、timeStamp、nonceStr、package计算得出的签名值
        file_put_contents("./wechatpay_notify.txt", date('Y-m-d H:i:s', time()) . $openid . '----openid----' . json_encode($data) . "\n", FILE_APPEND);

        return $data;
    }

    /**
     * @author: zwx
     * @Description: 签名方法
     * @param {*} $appId   公众号id
     * @param {*} $timeStamp  时间戳
     * @param {*} $nonceStr  随机数
     * @param {*} $package  prepay_id
     * @Date: 2024-05-21 15:49:12
     */
    public static function makeSign($appId, $timeStamp, $nonceStr, $package)
    {
        //本地
        //$merchantPrivateKeyFilePath = 'file:///usr/local/var/www/siyu/app/apiadmin/keys/apiclient_key.pem';
        //线上
        $merchantPrivateKeyFilePath = 'file:///data/siyu/app/apiadmin/keys/apiclient_key.pem';
        $merchantPrivateKeyInstance = Rsa::from($merchantPrivateKeyFilePath);

        return Rsa::sign(
            Formatter::joinedByLineFeed($appId, $timeStamp, $nonceStr, $package),
            $merchantPrivateKeyInstance
        );

    }

    /**
     * @author: zwx
     * @Description: 验签解密
     * @Date: 2024-05-25 17:29:13
     */
    public static function yanqian_jiemi()
    {
        $inWechatpaySignature = $_SERVER['HTTP_WECHATPAY_SIGNATURE']; // 请根据实际情况获取
        $inWechatpayTimestamp = $_SERVER['HTTP_WECHATPAY_TIMESTAMP']; // 请根据实际情况获取
        $inWechatpaySerial = ''; // 请根据实际情况获取
        $inWechatpayNonce = $_SERVER['HTTP_WECHATPAY_NONCE']; // 请根据实际情况获取
        $inBody = file_get_contents('php://input');
        // 请根据实际情况获取，例如: file_get_contents('php://input');

        $apiv3Key = 'f64b52db3091713e1129b36fc90ce3b5'; // 在商户平台上设置的APIv3密钥

        // 根据通知的平台证书序列号，查询本地平台证书文件，
        // 假定为 `/path/to/wechatpay/inWechatpaySerial.pem`
        $platformPublicKeyInstance = Rsa::from('file:///data/siyu/app/apiadmin/keys/wechatpay_489D311734468E3F64E38571CC002408745DDCB5.pem', Rsa::KEY_TYPE_PUBLIC);

        // 检查通知时间偏移量，允许5分钟之内的偏移
        $timeOffsetStatus = 300 >= abs(Formatter::timestamp() - (int) $inWechatpayTimestamp);
        $verifiedStatus = Rsa::verify(
            // 构造验签名串
            Formatter::joinedByLineFeed($inWechatpayTimestamp, $inWechatpayNonce, $inBody),
            $inWechatpaySignature,
            $platformPublicKeyInstance
        );
        if ($timeOffsetStatus && $verifiedStatus) {
            // 转换通知的JSON文本消息为PHP Array数组
            $inBodyArray = (array) json_decode($inBody, true);

            $ciphertext = $inBodyArray['resource']['ciphertext'];
            $nonce = $inBodyArray['resource']['nonce'];
            $associated_data = $inBodyArray['resource']['associated_data'];
            // 加密文本消息解密
            $inBodyResource = AesGcm::decrypt($ciphertext, $apiv3Key, $nonce, $associated_data);
            // 把解密后的文本转换为PHP Array数组
            $inBodyResourceArray = (array) json_decode($inBodyResource, true);

            return $inBodyResourceArray;
        }
    }

    /**
     * @author: zwx
     * @Description: 微信支付回调接口
     * @Date: 2024-05-23 11:34:01
     */
    public function notify()
    {

        $inWechatpaySignature = $_SERVER['HTTP_WECHATPAY_SIGNATURE']; // 请根据实际情况获取
        $inWechatpayTimestamp = $_SERVER['HTTP_WECHATPAY_TIMESTAMP']; // 请根据实际情况获取
        $inWechatpaySerial = ''; // 请根据实际情况获取
        $inWechatpayNonce = $_SERVER['HTTP_WECHATPAY_NONCE']; // 请根据实际情况获取
        $inBody = file_get_contents('php://input');
        // 请根据实际情况获取，例如: file_get_contents('php://input');

        $apiv3Key = 'f64b52db3091713e1129b36fc90ce3b5'; // 在商户平台上设置的APIv3密钥

        // 根据通知的平台证书序列号，查询本地平台证书文件，
        // 假定为 `/path/to/wechatpay/inWechatpaySerial.pem`
        $platformPublicKeyInstance = Rsa::from('file:///data/siyu/app/apiadmin/keys/wechatpay_489D311734468E3F64E38571CC002408745DDCB5.pem', Rsa::KEY_TYPE_PUBLIC);

        // 检查通知时间偏移量，允许5分钟之内的偏移
        $timeOffsetStatus = 300 >= abs(Formatter::timestamp() - (int) $inWechatpayTimestamp);
        $verifiedStatus = Rsa::verify(
            // 构造验签名串
            Formatter::joinedByLineFeed($inWechatpayTimestamp, $inWechatpayNonce, $inBody),
            $inWechatpaySignature,
            $platformPublicKeyInstance
        );
        if ($timeOffsetStatus && $verifiedStatus) {
            // 转换通知的JSON文本消息为PHP Array数组
            $inBodyArray = (array) json_decode($inBody, true);

            $ciphertext = $inBodyArray['resource']['ciphertext'];
            $nonce = $inBodyArray['resource']['nonce'];
            $associated_data = $inBodyArray['resource']['associated_data'];
            // 加密文本消息解密
            $inBodyResource = AesGcm::decrypt($ciphertext, $apiv3Key, $nonce, $associated_data);
            // 把解密后的文本转换为PHP Array数组
            $inBodyResourceArray = (array) json_decode($inBodyResource, true);
            file_put_contents("./wechatpay_notify.txt", date('Y-m-d H:i:s', time()) . '----支付回调通知----' . $inBodyResource . "\n", FILE_APPEND);

            //处理订单
            self::updateOrder($inBodyResourceArray);
            //处理定金
            self::updateDeposit($inBodyResourceArray);
        }

    }

    /**
     * @author: zwx
     * @Description: 更新订单状态
     * @param {*} $res
     * @Date: 2024-05-23 11:33:33
     */
    public function updateOrder($res)
    {

        $transaction_id = $res['transaction_id'];
        $out_trade_no = $res['out_trade_no'];
        $mchid = $res['mchid'];
        $attach = $res['attach'];
        $appid = $res['appid'];
        $trade_state_desc = $res['trade_state_desc'];
        $trade_type = $res['trade_type']; //交易类型，枚举值： JSAPI：公众号支付 NATIVE：扫码支付 App：App支付
        //MICROPAY：付款码支付 MWEB：H5支付 FACEPAY：刷脸支付
        $trade_state = $res['trade_state']; //交易状态，枚举值： SUCCESS：支付成功 REFUND：转入退款 NOTPAY：未支付
        //CLOSED：已关闭 REVOKED：已撤销（付款码支付） USERPAYING：用户支付中（付款码支付） PAYERROR：支付失败(其他原因，如银行返回失败)
        $total = $res['amount']['total'];
        $payer_total = $res['amount']['payer_total'];

        $dateTimeString = $res['success_time'];
        // 创建DateTime对象
        $dateTime = new DateTime($dateTimeString);
        // 设置时区
        $timeZone = new DateTimeZone('Asia/Shanghai'); // 或者使用 '+08:00' 替换
        $dateTime->setTimeZone($timeZone);
        // 转换为时间戳
        $timestamp = $dateTime->getTimestamp(); //支付成功时间
        // 业务参数
        // list($liveId,$user_id,$event_id,$courseid,$key,$deposit_id,$deposit_ids)=explode(',',$res['attach']);

        $o = DB::table('xh_siyu_order')->where(array('order_num' => $out_trade_no))->find();

        if ($o) {
            if ($trade_state == 'SUCCESS') {
                $order = DB::table('xh_siyu_order')->where(array('order_num' => $out_trade_no))->find();
                if ($order['state'] == 1) {
                    echo '{code:"200",message:"成功"}';
                    return;
                }

                // 获取公域订单
                $unionId = Db::table('xh_siyu_user_order_zhujiao_log')->where(['live_id' => $o['liveId'], 'user_id' => $o['user_id']])->value('xh_order_union_id');
                //如果是链接购买
                if (!$unionId) {
                    $unionId = $o['wx_unionid'];
                }
                $orderId = LiveManagerService::checkXhOrder($unionId);

                $data = array();
                $data['pay_time'] = date('Y-m-d H:i:s', $timestamp);

                $data['fee'] = $total;
                $data['payer_total'] = $payer_total;
                $data['state'] = 1;
                $data['trade_type'] = $trade_type;
                $data['pay_method'] = 1;
                $data['mchid'] = $mchid;
                $data['appid'] = $appid;
                $data['transaction_id'] = $transaction_id;
                $data['trade_state_desc'] = $trade_state_desc;
                $data['order_id'] = !empty($orderId) ? $orderId : 0;
                DB::table('xh_siyu_order')->where(array('order_num' => $out_trade_no))->save($data);
                //删除改价key
                if ($o['key']) {
                    $redis = \app\apiadmin\service\data\RedisService::makeService();
                    $redis->del($o['key']);
                }
                //关联定金
                if ($o['deposit_ids']) {
                    $deposit_ids = explode(',', $o['deposit_ids']);
                    if ($deposit_ids) {
                        foreach ($deposit_ids as $id) {
                            $data = [
                                'siyu_order_id' => $o['id'],
                            ];
                            DB::table('xh_siyu_deposit')->where(array('id' => $id))->save($data);
                        }
                    }
                }

                //打日志，做记录
                $m = [];
                $m['liveId'] = $o['liveId'];
                $m['live_user_id'] = $o['user_id'];
                $s = db::table('xh_siyu_invitation_user_signin')->where($m)->find();
                if ($s) {
                    $a = [];
                    $a['chengjiao'] = 3;
                    $a['chengjiao_time'] = date('Y-m-d H:i:s');
                    $a['order_num'] = $o['order_num'];
                    db::table('xh_siyu_invitation_user_signin')->where($m)->save($a);
                } else {
                    $a = [];
                    $a['liveId'] = $o['liveId'];
                    $a['live_user_id'] = $o['user_id'];
                    $a['order_num'] = $o['order_num'];
                    $a['chengjiao'] = 3;
                    $a['chengjiao_time'] = date('Y-m-d H:i:s');
                    db::table('xh_siyu_invitation_user_signin')->insertGetId($a);
                }

                //统计提单数据
                $liveId = $o['liveId']; // 直播ID
                $liveStatus = new LiveStatus($liveId);
                $liveStatus->set_xiaoshoue_yifukuan($total);
                $liveStatus->set_xiadan_danshu_yifukuan($out_trade_no);
                $liveStatus->set_xiadan_rensu_yifukuan($o['user_id']);

                $liveStatus->remove_xiaoshoue_weifukuan($total);
                $liveStatus->remove_xiadan_danshu_weifukuan($out_trade_no);
                $liveStatus->remove_xiadan_renshu_weifukuan($o['user_id']);

                $liveStatus->setGoodsSaleAmount($liveId, $o['courseid'], $o['fee']);
                $liveStatus->setGoodSaleCount($liveId, $o['courseid'], 1);

                //更新行为记录添加数据详情
                // $collection = 'live_order';
                // $map = [];
                // $map['liveId'] = $liveId;
                // $map['order_num'] = $out_trade_no;

                // $update = ['$set' => ['pay_time' => date('Y-m-d H:i:s',$timestamp),'state'=>1]];
                // $liveOrder = new LiveUserGetDataService($collection);
                // $liveOrder->updateOrder($map,$update);

                //行为记录添加数据详情
                $collection = 'live_event';
                $liveOrder = new LiveUserGetDataService($collection);
                $map = [];
                $map['user_id'] = $o['user_id'];
                $map['liveId'] = $liveId;

                $update = ['$set' => ['event' => '下单']];
                $r = $liveOrder->updateEvent($map, $update);

                //  订单支付完成后的操作
                MyOrder::afterPayOrder($o);

                // 新增/修改 公域订单状态
                if (!empty($orderId)) {
                    $session = Db::table('xh_siyu_live_manager')->where('id', $liveId)->value('venue');
                    LiveManagerService::getLiveOrderState($liveId, $session, $orderId, 3, $o['wx_unionid'], $o['tutorId'], $o['id'], $o['fee']);
                }

                echo '{code:"200",message:"成功"}';
            } else if ($trade_state == 'CLOSED') {
                $data = array();
                $data['state'] = 5;
                $data['trade_state_desc'] = $trade_state_desc;
                DB::table('xh_siyu_order')->where(array('order_num' => $out_trade_no))->save($data);
                echo '{code:"FAIL",message:"失败"}';
            } else if ($trade_state == 'PAYERROR') {
                $data = array();
                $data['trade_state_desc'] = $trade_state_desc;
                DB::table('xh_siyu_order')->where(array('order_num' => $out_trade_no))->save($data);
                echo '{code:"FAIL",message:"失败"}';
            }
        }

    }
    //更新定金状态
    public function updateDeposit($res)
    {
        $transaction_id = $res['transaction_id'];
        $out_trade_no = $res['out_trade_no'];
        $mchid = $res['mchid'];
        $attach = $res['attach'];
        $appid = $res['appid'];
        $trade_state_desc = $res['trade_state_desc'];
        $trade_type = $res['trade_type']; //交易类型，枚举值： JSAPI：公众号支付 NATIVE：扫码支付 App：App支付
        //MICROPAY：付款码支付 MWEB：H5支付 FACEPAY：刷脸支付
        $trade_state = $res['trade_state']; //交易状态，枚举值： SUCCESS：支付成功 REFUND：转入退款 NOTPAY：未支付
        //CLOSED：已关闭 REVOKED：已撤销（付款码支付） USERPAYING：用户支付中（付款码支付） PAYERROR：支付失败(其他原因，如银行返回失败)
        $total = $res['amount']['total'];
        $payer_total = $res['amount']['payer_total'];

        $dateTimeString = $res['success_time'];
        // 创建DateTime对象
        $dateTime = new DateTime($dateTimeString);
        // 设置时区
        $timeZone = new DateTimeZone('Asia/Shanghai'); // 或者使用 '+08:00' 替换
        $dateTime->setTimeZone($timeZone);
        // 转换为时间戳
        $timestamp = $dateTime->getTimestamp(); //支付成功时间

        $o = DB::table('xh_siyu_deposit')->where(array('deposit_num' => $out_trade_no))->find();

        if ($o) {
            if ($trade_state == 'SUCCESS') {
                $order = DB::table('xh_siyu_deposit')->where(array('deposit_num' => $out_trade_no))->find();
                if ($order['state'] == 1) {
                    echo '{code:"200",message:"成功"}';
                    return;
                }

                $data = array();
                $data['pay_time'] = date('Y-m-d H:i:s', $timestamp);

                $data['fee'] = $total;
                $data['actual_payment_fee'] = $payer_total;
                $data['state'] = 1;
                $data['trade_type'] = $trade_type;
                $data['pay_method'] = 1;
                $data['mchid'] = $mchid;
                $data['appid'] = $appid;
                $data['transaction_id'] = $transaction_id;
                $data['trade_state_desc'] = $trade_state_desc;
                DB::table('xh_siyu_deposit')->where(array('deposit_num' => $out_trade_no))->save($data);
                echo '{code:"200",message:"成功"}';
            } else if ($trade_state == 'CLOSED') {
                $data = array();
                $data['trade_state_desc'] = $trade_state_desc;
                DB::table('xh_siyu_deposit')->where(array('deposit_num' => $out_trade_no))->save($data);
                echo '{code:"FAIL",message:"失败"}';
            } else if ($trade_state == 'PAYERROR') {
                $data = array();
                $data['trade_state_desc'] = $trade_state_desc;
                DB::table('xh_siyu_deposit')->where(array('deposit_num' => $out_trade_no))->save($data);
                echo '{code:"FAIL",message:"失败"}';
            }
        }
    }

    /**
     * @author: zwx
     * @Description: 申请退款
     * @param {*} $order_num  订单号
     * @param {*} $fee  总订单金额
     * @param {*} $payer_total  实际支付金额
     * @Date: 2024-05-25 11:07:01
     */
    public static function tuikuan($order_num, $refund_num, $fee, $payer_total)
    {

        $url = 'https://api.mch.weixin.qq.com/v3/refund/domestic/refunds';

        $amount = array();
        $amount['refund'] = intval($payer_total);
        $amount['total'] = intval($fee);
        $amount['currency'] = 'CNY';

        $json = array();
        $json['out_refund_no'] = $refund_num;
        $json['out_trade_no'] = $order_num;
        $json['amount'] = $amount;
        $json['notify_url'] = 'https://liveapi.banxued.com/apiadmin/unionapp/tuikuan_notify';

        $result = self::client_post($url, $json);

        return $result;

    }

    /**
     * @author: zwx
     * @Description: 微信支付退款回调接口
     * @Date: 2024-05-25 17:22:30
     */
    public function tuikuan_notify()
    {
        $inBodyResourceArray = self::yanqian_jiemi();

        file_put_contents("./wechatpay_tuikuan_notify.txt", date('Y-m-d H:i:s', time()) . '----退款回调通知----' . json_encode($inBodyResourceArray) . "\n", FILE_APPEND);

        //更新退单状态
        self::updateSelledOrder($inBodyResourceArray);

    }

    /**
     * @author: zwx
     * @Description: 更新退单状态
     * @param {*} $data
     * @Date: 2024-05-25 17:32:51
     */
    public function updateSelledOrder($data)
    {
        $res = Db::name('siyu_deposit')->where(['deposit_num' => $data['out_trade_no']])->find();
        if ($res && $res['state'] == 1 && 'T' . $data['out_trade_no'] == $data['out_refund_no']) {
            Db::name('siyu_deposit')->where(['id' => $res['id']])->update(['state' => 2]);
            echo '{code:"200",message:"成功"}';
            return;
        }

        try {
            $where['order_num'] = $data['out_trade_no'];

            $selledWhere['order_num'] = $data['out_trade_no'];
            $selledWhere['refund_num'] = $data['out_refund_no'];
            $o = DB::table('xh_siyu_order')->where($where)->find();
            $selledOrder = DB::table('xh_siyu_order_selled')->where($selledWhere)->find();
            if ($o) {
                if ($selledOrder && $selledOrder['state'] == 1 && $o['state'] == 3) {
                    echo '{code:"200",message:"成功"}';
                    return;
                }
                $map = array();
                $map1 = array();
                if ($data['refund_status'] == 'SUCCESS') {
                    $map['state'] = 1;
                    $map1['state'] = 3;
                    $dateTimeString = $data['success_time'];
                    // 创建DateTime对象
                    $dateTime = new DateTime($dateTimeString);
                    // 设置时区
                    $timeZone = new DateTimeZone('Asia/Shanghai'); // 或者使用 '+08:00' 替换
                    $dateTime->setTimeZone($timeZone);
                    // 转换为时间戳
                    $success_time = $dateTime->getTimestamp();

                    $map['pay_time'] = date('Y-m-d H:i:s', $success_time);

                    DB::table('xh_siyu_order_selled')->where($selledWhere)->save($map);
                    if ($o['state'] != 3) {
                        //统计提单数据
                        $liveId = $o['liveId']; //透传参数  直播ID
                        $liveStatus = new LiveStatus($liveId);
                        $liveStatus->set_xiaoshoue_tuikuan($data['amount']['refund']);
                        $liveStatus->set_xiadan_danshu_tuikuan($o['order_num']);
                        $liveStatus->set_xiadan_renshu_tuikuan($o['user_id']);
                        DB::table('xh_siyu_order')->where($where)->save($map1);
                    }

                    //给公域订单打标记
                    $where = [];
                    $where['id'] = $o['order_id'];
                    $gongyuorder = DB::table('xh_order_1')->where($where)->find();
                    if ($gongyuorder) {
                        $data = [];
                        $data['new_tuikuan_tag'] = 1;
                        $data['new_tuikuan_time'] = $map['pay_time'];
                        db::table('xh_order_1')->where($where)->save($data);
                    }
                    echo '{code:"200",message:"成功"}';
                } else if ($data['refund_status'] == 'CLOSED') {
                    $map['state'] = 2;
                    $map1['state'] = 6;
                    DB::table('xh_siyu_order_selled')->where($selledWhere)->save($map);
                    if ($o['state'] != 3) {
                        DB::table('xh_siyu_order')->where($where)->save($map1);
                    }
                    echo '{code:"FAIL",message:"失败"}';
                } else if ($data['refund_status'] == 'ABNORMAL') {
                    $map['state'] = 4;
                    $map1['state'] = 4;
                    DB::table('xh_siyu_order_selled')->where($selledWhere)->save($map);
                    if ($o['state'] != 3) {
                        DB::table('xh_siyu_order')->where($where)->save($map1);
                    }
                    echo '{code:"FAIL",message:"失败"}';
                }
            }

            echo '{code:"200",message:"成功"}';
        } catch (\Exception $e) {
            return Res::error($e->getMessage());
        }

    }

    /**
     * @author: zwx
     * @Description: 创建clientt
     * 平台证书下载：composer exec CertificateDownloader.php -- -k f64b52db3091713e1129b36fc90ce3b5 -m 1674971019 -f C:\workspace\maomaochong\siyu\siyu\app\apiadmin\keys\apiclient_key.pem -s 73B9DF9ADD125E24801014EB95827EA0392B020F -o C:\workspace\maomaochong\siyu\siyu\app\apiadmin\keys
     * @Date: 2024-05-19 15:11:43
     */
    public static function createClient()
    {

        // 商户号
        $merchantId = '1674971019';

        // 从本地文件中加载「商户API私钥」，「商户API私钥」会用来生成请求的签名
        //$merchantPrivateKeyFilePath = "file:///usr/local/var/www/siyu/app/apiadmin/keys/apiclient_key.pem";

        $merchantPrivateKeyFilePath = 'file:///data/mmc/api/app/apiadmin/keys/apiclient_key.pem';

        $merchantPrivateKeyInstance = Rsa::from($merchantPrivateKeyFilePath, Rsa::KEY_TYPE_PRIVATE);

        // 「商户API证书」的「证书序列号」
        $merchantCertificateSerial = '73B9DF9ADD125E24801014EB95827EA0392B020F';

        // 从本地文件中加载「微信支付平台证书」，用来验证微信支付应答的签名
        //$platformCertificateFilePath = "file:///usr/local/var/www/siyu/app/apiadmin/keys/wechatpay_489D311734468E3F64E38571CC002408745DDCB5.pem";

        $platformCertificateFilePath = 'file:///data/mmc/api/app/apiadmin/keys/wechatpay_489D311734468E3F64E38571CC002408745DDCB5.pem';
        $platformPublicKeyInstance = Rsa::from($platformCertificateFilePath, Rsa::KEY_TYPE_PUBLIC);

        // 从「微信支付平台证书」中获取「证书序列号」
        $platformCertificateSerial = PemUtil::parseCertificateSerialNo($platformCertificateFilePath);

        // 构造一个 APIv3 客户端实例
        $instance = Builder::factory([
            'mchid' => $merchantId,
            'serial' => $merchantCertificateSerial,
            'privateKey' => $merchantPrivateKeyInstance,
            'certs' => [
                $platformCertificateSerial => $platformPublicKeyInstance,
            ],
        ]);

        return $instance;

    }

    /**
     * @author: zwx
     * @Description: 微信支付get请求  异步
     * @param {*} $url  请求url
     * @Date: 2024-05-19 15:21:04
     */
    public static function client_get($url)
    {

        $instance = self::createClient();

        try {
            $resp = $instance
                ->chain($url)
                ->get();

            $data = array();
            $data['code'] = $resp->getStatusCode();
            $data['msg'] = '成功';
            $data['body'] = $resp->getBody();

            return $data;
        } catch (\Exception $e) {
            // 进行错误处理
            if ($e instanceof \GuzzleHttp\Exception\RequestException  && $e->hasResponse()) {
                $r = $e->getResponse();
                $data = array();
                $data['code'] = $r->getStatusCode();
                $data['msg'] = $r->getReasonPhrase();
                $data['body'] = $e->getMessage();

                return $data;
            }
            echo $e->getTraceAsString(), PHP_EOL;
        }

    }

    /**
     * @author: zwx
     * @Description: 微信支付post请求
     * @param {*} $url   请求url
     * @param {*} $json  json请求体
     * @Date: 2024-05-19 15:21:22
     */
    public static function client_post($url, $json)
    {
        $instance = self::createClient();

        try {
            $resp = $instance
                ->chain($url)
                ->post(['json' => $json]);

            $data = array();
            $data['code'] = $resp->getStatusCode();
            $data['msg'] = '成功';
            $data['body'] = $resp->getBody();

            return $data;
        } catch (\Exception $e) {
            // 进行错误处理
            if ($e instanceof \GuzzleHttp\Exception\RequestException  && $e->hasResponse()) {
                $r = $e->getResponse();
                $data = array();
                $data['code'] = $r->getStatusCode();
                $data['msg'] = $r->getReasonPhrase();
                $data['body'] = $e->getMessage();

                return $data;
            }
            echo $e->getTraceAsString(), PHP_EOL;
        }

    }

    /**
     * @author: zwx
     * @Description: 获取商品详情信息
     * @Date: 2024-05-16 09:49:51
     */
    public function getGoodsInfo()
    {

        $param = $this->request->post();
        $result = UnionAppService::getGoodsInfo($param);

        return Res::ok($result);

    }

    /**
     * @author: zwx
     * @Description: 获取商品详情信息  购买链接
     * @Date: 2024年7月7日17:24:55
     */
    public function getShangpinInfo()
    {

        $param = $this->request->post();
        $result = UnionAppService::getShangpinInfo($param);

        return Res::ok($result);

    }

    /**
     * @author: zwx
     * @Description: 加载弹卡信息   废弃 2024年5月26日17:56:16
     * @Date: 2024-05-17 15:39:19
     */
    public function getTanKaInfo()
    {

        $param = $this->request->post();
        $result = UnionAppService::getTanKaInfo($param);
        return Res::ok($result);
    }

    /**
     * @author: zwx
     * @Description: 用户进入直播间时间
     * @Date: 2024-06-13 19:01:09
     */
    public function entertime()
    {

        $param = $this->request->post();
        $result = UnionAppService::entertime($param);
        return Res::ok($result);

    }

    /**
     * @author: zwx
     * @Description: 用户退出直播间时间
     * @Date: 2024-06-13 19:01:25
     */
    public function exittime()
    {

        $param = $this->request->post();
        $result = UnionAppService::exittime($param);
        return Res::ok($result);

    }

//给销售倒邀约数据
    public function chengjiaodata()
    {

        $liveId = 183;

        $invitation = db::table('xh_siyu_invitation_user')
            ->alias('u')
            ->field('u.*,m.nick_name')
            ->join(['xh_siyu_sys_member' => 'm'], 'm.user_name=u.sender', 'left')
            ->where(['liveId' => $liveId])->group('u.wx_unionid')->select()->toArray(); //邀约人

        $unions = [];

        foreach ($invitation as $k => $v) {
            if (!empty($v['wx_unionid'])) {
                $unions[] = $v['wx_unionid'];
            }
        }

        $map = [];
        $map[] = ['unionid', 'in', $unions];
        $users = db::table('xh_siyu_user')->where($map)->select()->toArray(); //用户

        $map = [];
        $map['liveId'] = $liveId;
        $map[] = ['state', 'in', [1, 2, 3, 4]];
        $orders = db::table('xh_siyu_order')->where($map)->select()->toArray(); //订单

        foreach ($invitation as $k => $v) {
            $invitation[$k]['signin_status2'] = '未到课';
            $invitation[$k]['chengjiao_status2'] = '未成交';
            $invitation[$k]['nickname2'] = '';
            $invitation[$k]['phone'] = '';
            $invitation[$k]['order_num'] = '';

            if ($v['signin_status'] == 2) {
                $invitation[$k]['signin_status2'] = '已到课';
            }

            if ($v['chengjiao_status'] == 2) {
                $invitation[$k]['chengjiao_status2'] = '已成交';
            }

            foreach ($users as $k1 => $v1) {
                if ($v['wx_unionid'] == $v1['unionid']) {
                    $invitation[$k]['nickname2'] = $v1['nickname'];
                    $invitation[$k]['phone'] = $v1['phone'];
                }
            }

            foreach ($orders as $k2 => $v2) {
                if ($v['wx_unionid'] == $v2['wx_unionid']) {
                    $invitation[$k]['order_num'] = $v2['order_num'];
                    $invitation[$k]['phone'] = $v2['tel'];
                }

            }
            echo $invitation[$k]['nickname2'] . ',' . $invitation[$k]['phone'] . ',' . $invitation[$k]['nick_name'] . ',' . $invitation[$k]['signin_status2'] . ',' . $invitation[$k]['chengjiao_status2'] . ',' . $invitation[$k]['order_num'] . '/n';
        }

    }

    /**
     * @author: zwx
     * @Description:
     * @Date: 2024-07-22 22:03:00
     */
    public function shuashu()
    {
        $liveId = 223;

        $session = 1;
        $unionId = ['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13SqDw', 'ogn1qw3y5ZsPokO9nu9oq6GR7goA', 'ogn1qwxpE7F-6GHQEP3d002aYuy0', 'ogn1qw08UBkKS8PjM9qKTVVfvrIM', 'ogn1qw812qUlvirJQ-p9i8eaMy4k', 'ogn1qw0EKWyP2_5lfltyW17wqhL4', 'ogn1qw9GrFUAozZCXShL-pMex990', 'ogn1qwwp9f1DiehmiFlVt08wXhZI', 'ogn1qwygtiRc0_IU-RgDkqSxeBQo', 'ogn1qwxJit0XOuOEI0FKC8UwXK6E', 'ogn1qw3XfYhvnG75cYUJYIgNzdAg', 'ogn1qw1Ohnh_TZ-C-o057ElgV2NA', 'ogn1qwwGfxyyAy7eYB2ZeuRM6_fA', 'ogn1qw_poj2buQh9FZtaO5WjWLP0', 'ogn1qw3CZ_iDVdKOyJV-UdiewrCw', 'ogn1qw-xDxPLoz75Lw_xB53OXdmY', 'ogn1qw7UfV2ubgL9PO5pVkljP1kg', 'ogn1qw9jhrkWw6-fvel4-tXtYypQ', 'ogn1qw5nO1vyTwgcGcQe6OckGsO8', 'ogn1qwwQ51XsD8meM4ogUC-3xec4', 'ogn1qw-DPQcLKVaaM7RH4_Fc2Fcw', 'ogn1qw4owLsUm88u7BqJkcEWDcqs', 'ogn1qwzEIrPWgh9j0DLi_G1zWLHQ'];

        $where = [];
        $where[] = ['wx_union_id', 'in', $unionId];
        $where[] = ['pay_state', '=', 1];
        $where[] = ['del', '=', 0];
        $where[] = ['is_association_siyu', '=', 0];
        $where[] = ['pay_time', '<', date('Y-m-d H:i:s')];
        $where[] = ['pingtai', 'IN', [1, 2, 4, 6]];
        $orderArray = Db::table('xh_order_1')->where($where)->field('id,wx_union_id');

        foreach ($orderArray as $value) {
            if (!empty($unionId)) {
                self::getLiveOrderState($liveId, $session, $value['id'], 2, $value['wx_union_id']);
            }
        }
    }

    /**
     * 直播订单状态更改   刷数据专用  2024年7月22日21:58:05
     * @param $liveId   '直播间id'
     * @param $session  '场次'
     * @param $orderId  '公域订单id'
     * @param $type     '当前状态 0：无、1:邀约、2:到课、3:成交'
     * @param $unionId  '用户union_id'
     * @param $tutorId  '邀请人id'
     * @param $siyuId   '私域订单id'
     * @param $money    '成交金额'
     * @return bool|string
     * @author cc
     */
    public static function getLiveOrderState($liveId, $session, $orderId, $type, $unionId = '', $tutorId = '', $siyuId = '', $money = '')
    {

        try {
            $orderInfo = Db::table('xh_order_1')->where('id', $orderId)->find();
            if (!$orderInfo) {
                throw new \Exception("订单不存在!");
            }
            $date = date('Y-m-d H:i:s');
            $data = [];
            switch ($type) {
                case 1:
                    $data = [
                        'new_yaoyue_tag' => 1,
                        'new_yaoyue_tag_time' => $date,
                    ];
                    break;
                case 2:
                    $data = [
                        'new_daoke_tag' => 1,
                        'new_daoke_tag_time' => $date,
                    ];
                    break;
                case 3:
                    $data = [
                        'new_chengjiao_tag' => 1,
                        'new_chengjiao_tag_time' => $date,
                    ];
                    break;
                default:
                    break;
            }

            if ($type != 0 && !empty($data)) {
                // 修改 order_1 订单状态
                Db::table('xh_order_1')->where('id', $orderId)->update($data);
            }

            // 新增/修改 直播订单状态
            $orderLiveDetail = Db::table('xh_order_live_detail')->where(['order_id' => $orderInfo['id'], 'live_id' => $liveId, 'session' => $session])->find();
            if (!$orderLiveDetail) {
                if ($type == 1) {
                    $data = [
                        'order_id' => $orderInfo['id'],
                        'live_id' => $liveId,
                        'session' => $session,
                        'type' => $type,
                        'del' => 0,
                        'time' => $date,
                    ];
                    Db::table('xh_order_live_detail')->insert($data);
                }
            } else {
                Db::table('xh_order_live_detail')->where('id', $orderLiveDetail['id'])->update(['type' => $type]);
            }

            return true;
        } catch (\PDOException $e) {
            throw $e;
        }
    }

    public function getUpdatePrice()
    {
        $param = $this->request->post();
        $result = UnionAppService::getUpdatePrice($param);
        if (!$result) {
            return Res::ok(['fee' => 0]);
        }
        if ($param['courseid'] != $result['siyu_course_id']) {
            return Res::ok(['fee' => 0]);
        }
        $fee = $result['fee'];
        $deposit_ids = [];
        if ($result['type'] == 'deposit' && isset($result['siyu_deposit_id'])) {
            $deposit_ids[] = $result['siyu_deposit_id'];
        }
        // $deposit_ids=[];
        // if(isset($param['user_id']) && isset($param['courseid'])){
        //     $where=[
        //         'siyu_course_id'=>$param['courseid'],
        //         'user_id'=>$param['user_id'],
        //         'state'=>1,
        //         'siyu_order_id'=>0
        //     ];
        //     $deposit_list = Db::name('siyu_deposit')->where($where)->select()->toArray();
        //     if($deposit_list){
        //         foreach($deposit_list as $item){
        //             $fee-=$item['actual_payment_fee'];
        //             $deposit_ids[]=$item['id'];
        //         }
        //     }
        // }

        return Res::ok(['fee' => $fee, 'xianjia' => '¥' . $fee / 100, 'deposit_ids' => $deposit_ids]);
    }

    public function getDepositInfo()
    {
        $param = $this->request->post();
        $deposit_service = \app\apiadmin\service\deposit\DepositService::getInstance();
        $result = $deposit_service->info($param);
        if ($result) {
            if ($result['state'] != 0) {
                return Res::ok([]);
            }
            $result['fee_name'] = bcdiv($result['fee'], 100, 2);
            $result['xianjia'] = '¥' . $result['fee_name'];
        }

        return Res::ok($result);
    }

    public function syncUserDeposit()
    {
        $param = $this->request->post();
        $deposit_service = \app\apiadmin\service\deposit\DepositService::getInstance();
        $result = $deposit_service->bindUser($param);
        if (!$result['res']) {
            return Res::error($result['msg']);
        }
        $pay_method = $param['pay_method'];
        $deposit_info = $result['res'];
        $course_info = Db::name('siyu_course')->where(['id' => $deposit_info['siyu_course_id']])->find();
        $data = [];
        switch ($pay_method) {
            case 1: //微信返回数据
                $result = $this->getWeChatPay($deposit_info, $course_info);
                break;
            case 2: //支付宝返回数据
                $result = $this->getAlipay($deposit_info, $course_info);
                break;
            default:
                $result = Res::error("支付方式错误");
                break;
        }
        return $result;
    }

    private function getWeChatPay($deposit_info, $course_info)
    {
        //账户信息
        $account = UnionAppFuWuShang::getFuWuShangAccount($deposit_info['pay_method']);
        //保存子账号信息
        $update_data = [
            'sub_mchid' => $account['sub_mchid'],
            'accountid' => $account['id'],
        ];
        $deposit_model = new \app\apiadmin\model\deposit\DepositModel();
        $where = ['id' => $deposit_info['id']];
        $deposit_model->edit($where, $update_data);

        $wx_openid = $deposit_info['wx_openid'];
        $fee = $deposit_info['fee'];
        $coursename = $course_info['name'];
        $courseid = $deposit_info['siyu_course_id'];
        $orderNumber = $deposit_info['deposit_num'];
        // 创建DateTime对象
        // $dateTime = new DateTime($deposit_info['update_time']);

        // 设置时区，如果需要的话
        // $dateTime->setTimezone(new DateTimeZone('Asia/Shanghai'));

        // 生成RFC3339格式的时间字符串
        // $timestamp = $dateTime->format(DateTime::RFC3339);
        $timestamp = time();
        $liveId = 0;

        $user_id = $deposit_info['user_id'];

        $event_id = '';

        $data = UnionAppFuWuShang::createPrepayId(
            $account,
            $wx_openid,
            $fee,
            $coursename,
            $courseid,
            $orderNumber,
            $timestamp,
            $liveId,
            $user_id,
            $event_id
        );
        return Res::ok($data);
    }

    private function getAlipay1($deposit_info, $course_info)
    {
        //配置支付宝相关参数
        $config = [
            //以下是正式环境的参数
            'alipay_appid' => '2021004147620033',
            'alipay_alipay_rsapublicKey' => 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhxB6iK/ic/9quQOow4pBuB7k4LrezPfx8rg1QYIU8Zvne5Ldh14FdUId4s19pd8km6j+n9gdMkKzBA4yGQxGzSII+fS7kVp1sfvNJiSIhVszdL1Kzpx1n+LPkedF4sXxBYoagPQsbRVo8IoPIl0iTvXZvU/crWMfulhXspTottUPrL1E7GZYP9Sr0GrKZID7IQOOsVYPNjgcqe4qVxrx0Qukaa4F4Roe6WiNM8FviQUWdZhds5mez+o+5Y5B0oE50N8qVemK7yLdAx9LphKTKhGWAvg8UC2pptez5xEtM6aVmgFYZz5Bzcmcrff0RM2BzADIch8IkI//1VtRpfv5uwIDAQAB',
            'alipay_rsaprivateKey' => 'MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCKjaocI+7fATTGEiyw2GyH61/ieyox2eD+ei0asaJDzxn07DbQpZ66u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s2z9Ru+u1TvjsacXztu00Sr1eM2iAGtL1RixfI7N8SKnJbQA5iHweB5x/8hrEm/7cWQDKuEHX+JX4b5T2CFNdR79VYVZpZCQKBgQCybdeff10Lf3uLo5O2/sxzc9GX/ZWU3ZNcFQE52esGGa/KIk02iSjQ20bNkOyAc9ebVo9JoJPydtBkKGW1IgOYaxvwPuP8YuK9MEcy1vdkvj4BeENH8Edf8HsjabEKUwbxRMsSenvXPpKH/g6MVrPDrHip6QRRq0Mp44tmYOCf4wKBgQCtDZo2+dIORMGaQquk2l0Z5/1koEe9izn0fI7UJeV5RPqHSSTjSfjSUhKqGN87o7HZ6gAbnOY/6hzRv/bNFtvvIZkP1AR5A2lc/gpsIGAxEJtHzJyuckfx6fRhkh4w4NMZ8b0KDO3BAbaDnH5qMINK074OXSEL5cIMUabgeAmOJg==',
            'alipay_notify' => 'https://liveapi.banxued.com/apiadmin/user/alipay_notify2',
            //以下是沙箱环境的参数
            //'alipay_appid' =>'9021000137631512',
            //'alipay_alipay_rsapublicKey' =>'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo7whnUDKUW8asSA4DGxRIvKA+NLY0rkJXYRLRQDY4QKvMe6S6GAgGgDIi8+USQDplscHumDPykTz0FDQJoS7SYzQcTUZgn15G4GbxFdqLRkokpIikfm2BpagtF/MZOsZkfX82zw43UOHJS1Y4k7BoDTSpifhf4RR+murN9bZvT17iqCSOhwGy84/epp91ad6mqmerzjCX4mYyNipTG+HrOw20iWdLas1PFo5edk6o7XZdnUByPYw6QdnwFTvOUvwIEuRVm7aoPE+x0w/Rl2fEogwWO7BSNPuyo3EU1u00cqy1wc0f+GhD59GSrtnoF3mcGuNBjfqjTX0UmlkE+i0jwIDAQAB',
            //'alipay_rsaprivateKey' =>'MIIEpAIBAAKCAQEAo7whnUDKUW8asSA4DGxRIvKA+NLY0rkJXYRLRQDY4QKvMe6S6GAgGgDIi8+USQDplscHumDPykTz0FDQJoS7SYzQcTUZgn15G4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tb/JAqERHlJXXFVRobUm2WwHr+Qjnyppqi+6gvBAQKBgQC3ACF7eGDa1n8gr2meaWwukJflCI4QfJDmStLbNeJCsKl9yaenWw7+K/BJ8imKhOsjjV38TgKcKDK5s5Uamt7RPNpYEBkvvDtduaPeMzTbOicsppkaPX/5d2fu1yxrvGemFe1V94Cgv1B2CE+F7171s4V/Hvc0Vk5maxNbfixEVQKBgQCpsdIdrUWizpATwvYhdp/oeb7/YWw/4Zqs/pSmJGYunD3BMwzLLWI71Gd9n0ui3ODlhkKY6SPkOQHNVKx6ZXbOmbxiDiNPDyfu5cHqakYdtve5ztz2qUHlGKuI5lYESrN7YqM4z1DOtp3uXsWm/Nle0+3rruZThr1HNOxCYLm6mg==',
            //'alipay_notify' =>'https://liveapi.banxued.com/apiadmin/user/alipay_notify',
            //支付宝回调地址 支付成功后支付宝会把消息发送给此接口，在此接口中完成支付成功后的相关操作即可
        ];

        $aop = new AopClient();

        //$aop->gatewayUrl = "https://openapi-sandbox.dl.alipaydev.com/gateway.do"; //网关地址要使用沙箱网关alipaydev
        $aop->gatewayUrl = "https://openapi.alipay.com/gateway.do"; //网关地址要使用沙箱网关alipaydev

        //支付宝分配给开发者的应用ID
        $aop->appId = $config['alipay_appid'];

        //请填写支付宝公钥，一行字符串
        $aop->alipayrsaPublicKey = $config['alipay_alipay_rsapublicKey'];

        //请填写开发者私钥去头去尾去回车，一行字符串
        $aop->rsaPrivateKey = $config['alipay_rsaprivateKey'];

        //返回数据格式
        $aop->format = "json";

        //表单提交字符集编码
        $aop->postCharset = "utf-8";

        //签名类型
        $aop->signType = "RSA2";

        //api版本
        $aop->apiVersion = '1.0';
        //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称：alipay.trade.app.pay
        $request = new AlipayTradeWapPayRequest();
        //SDK已经封装掉了公共参数，这里只需要传入业务参数，沙箱环境的product_code只能是FAST_INSTANT_TRADE_PAY
        $info = [
            'body' => $course_info['name'],
            'subject' => '定金支付',
            'out_trade_no' => $deposit_info['deposit_num'],
            'total_amount' => $deposit_info['fee'] / 100,
        ];
        $info = json_encode($info, JSON_UNESCAPED_UNICODE);

        //支付宝服务器主动通知商户服务器里指定的页面http/https路径。 支付回调
        $request->setNotifyUrl($config['alipay_notify']);
        $request->setReturnUrl(env('Live.live_host') . "/pages/animate/myorder/paysuccess?id=" . $deposit_info['id'] . '&type=deposit');
        $request->setBizContent($info);
        //这里和普通的接口调用不同，使用的是sdkExecute
        $data = $aop->pageExecute($request);

        $result = [
            'res' => true,
            'msg' => '获取支付宝支付信息成功',
            'data' => $data,
        ];
        return $result;
    }

    private function getAlipay($deposit_info, $course_info)
    {
        $where = [];
        if (isset($deposit_info['seller_id']) && !empty($deposit_info['seller_id'])) {
            $where[] = ['account', '=', $deposit_info['seller_id']];
            $where[] = ['del', '=', 0];
        } else {
            $where[] = ['flag', '=', 2];
            $where[] = ['state', '=', 1];
            $where[] = ['del', '=', 0];
        }
        $merchantInfo = Db::table('xh_siyu_fuwushang_account')->where($where)->find();
        if (!$merchantInfo) {
            return Res::error('暂时没有激活的支付宝商户！');
        }

        $config = config('alipay');

        $alipayClient = new AopClient();
        $alipayClient->gatewayUrl = $config['gatewayUrl'];
        $alipayClient->appId = $config['app_id'];
        $alipayClient->rsaPrivateKey = $config['merchant_private_key'];
        $alipayClient->alipayrsaPublicKey = $config['alipay_public_key'];
        $alipayClient->signType = "RSA2";
        $alipayClient->postCharset = "UTF-8";
        $alipayClient->format = "JSON";
        $alipayClient->apiVersion = "1.0";

        $info = [
            'out_trade_no' => $deposit_info['deposit_num'],
            'total_amount' => $deposit_info['fee'] / 100,
            'subject' => '定金支付',
            'body' => $course_info['name'],
            'product_code' => 'QUICK_WAP_WAY',
            'seller_id' => !empty($deposit_info['seller_id']) ? $deposit_info['seller_id'] : $merchantInfo['account'],
        ];
        $request = new AlipayTradeWapPayRequest();
        $request->setBizContent(json_encode($info));
        $request->setReturnUrl(env('Live.live_host') . "/pages/animate/myorder/paysuccess?id=" . $deposit_info['id'] . '&type=deposit');
        $request->setNotifyUrl($config['notify_url']);
        $pageRedirectionData = $alipayClient->pageExecute($request, "POST", $merchantInfo['sp_appid']);
        return Res::ok($pageRedirectionData);
    }
}
